<?php 
/**
 * ReadPress是一个优秀的主题，回归纯粹的博客，文艺、阅读、写作、摄影、展示wordpress主题
 * Gitee：https://gitee.com/MUCEO/readpress/
 * 作者唯一QQ：858896214 （秋知德雨）
 * QQ交流群：917367358
 * 开发者不易，感谢支持，如果使用本主题尽量留个版权或者链接
 */
?>
<?php
function example_theme_supportss() {
    $htkqzdytx = _read('zero-ht-htkqzdttx');
	if(!empty($htkqzdytx)){
require get_template_directory() . '/inc/author-avatars.php';
   }
}
add_action( 'init', 'example_theme_supportss' );
function example_theme_support() {
    $jyxgju = _read('zero-ht-jyxbxgj');
	if($jyxgju == true){
         remove_theme_support( 'widgets-block-editor' );
   }
}
add_action( 'after_setup_theme', 'example_theme_support' );
function example_theme_supports() {
    $jyxgjus =  _read('zero-ht-jyxbbjq');
	if($jyxgjus == true){
add_filter('use_block_editor_for_post', '__return_false');

   }
}
add_action( 'init', 'example_theme_supports' );
    function zero_wzl_category(){
    if (!empty(_read('zero-wzl-category'))) {
add_action( 'load-themes.php',  'no_category_base_refresh_rules');
add_action('created_category', 'no_category_base_refresh_rules');
add_action('edited_category', 'no_category_base_refresh_rules');
add_action('delete_category', 'no_category_base_refresh_rules');
function no_category_base_refresh_rules() {
    global $wp_rewrite;
    $wp_rewrite -> flush_rules();
}
add_action('init', 'no_category_base_permastruct');
function no_category_base_permastruct() {
    global $wp_rewrite, $wp_version;
    if (version_compare($wp_version, '3.4', '<')) {
        $wp_rewrite -> extra_permastructs['category'][0] = '%category%';
    } else {
        $wp_rewrite -> extra_permastructs['category']['struct'] = '%category%';
    }
}
add_filter('category_rewrite_rules', 'no_category_base_rewrite_rules');
function no_category_base_rewrite_rules($category_rewrite) {
    $category_rewrite = array();
    $categories = get_categories(array('hide_empty' => false));
    foreach ($categories as $category) {
        $category_nicename = $category -> slug;
        if ($category -> parent == $category -> cat_ID)// recursive recursion
            $category -> parent = 0;
        elseif ($category -> parent != 0)
            $category_nicename = get_category_parents($category -> parent, false, '/', true) . $category_nicename;
        $category_rewrite['(' . $category_nicename . ')/(?:feed/)?(feed|rdf|rss|rss2|atom)/?$'] = 'index.php?category_name=$matches[1]&feed=$matches[2]';
        $category_rewrite['(' . $category_nicename . ')/page/?([0-9]{1,})/?$'] = 'index.php?category_name=$matches[1]&paged=$matches[2]';
        $category_rewrite['(' . $category_nicename . ')/?$'] = 'index.php?category_name=$matches[1]';
    }
    global $wp_rewrite;
    $old_category_base = get_option('category_base') ? get_option('category_base') : 'category';
    $old_category_base = trim($old_category_base, '/');
    $category_rewrite[$old_category_base . '/(.*)$'] = 'index.php?category_redirect=$matches[1]';
    return $category_rewrite;
}
add_filter('query_vars', 'no_category_base_query_vars');
function no_category_base_query_vars($public_query_vars) {
    $public_query_vars[] = 'category_redirect';
    return $public_query_vars;
}
add_filter('request', 'no_category_base_request');
function no_category_base_request($query_vars) {
    if (isset($query_vars['category_redirect'])) {
        $catlink = trailingslashit(get_option('home')) . user_trailingslashit($query_vars['category_redirect'], 'category');
        status_header(301);
        header("Location: $catlink");
        exit();
    }
    return $query_vars;
}}}
if (!empty(_read('zero-wzl-category'))) {
add_action( 'after_setup_theme', 'zero_wzl_category' );
}
    function qgg_not_autosave() {
        wp_deregister_script('autosave');
    }
    function qgg_wp_revisions_to_keep( $num, $post ) {
        return 0;
    }
if(!empty(_read('rp-ht-draft'))){
 add_action('wp_print_scripts', 'qgg_not_autosave');
  add_filter( 'wp_revisions_to_keep', 'qgg_wp_revisions_to_keep', 10, 2 );
}
    function remove_screen_options(){ return false;}
        add_filter('screen_options_show_screen', 'remove_screen_options');
        add_filter( 'contextual_help', 'wpse50723_remove_help', 999, 3 );
        function wpse50723_remove_help($old_help, $screen_id, $screen){
        $screen->remove_help_tabs();
        return $old_help;
    }
    function example_remove_dashboard_widgets() {  
        global $wp_meta_boxes;  
        unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);  
        unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);  
        unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);  
        unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);  
        unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']);  
        unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);  
        unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);  
        unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);  
    }  
    add_action('wp_dashboard_setup', 'example_remove_dashboard_widgets' );  
function rc_my_welcome_panel() {
	?>
	<script type="text/javascript">
		jQuery(document).ready( function($) 
		{
			$('div.welcome-panel-content').hide();
		});
	</script>
	<div class="custom-welcome-panel-content">
	<div class="welcome-panel-header">
		<h2>欢迎使用 <asa style="font-weight: 800;background-image: linear-gradient(to right , #0DACB7, #71bd6a);-webkit-background-clip: text;-webkit-text-fill-color: transparent;">ReadPress</asa> 主题 与Wordpress！</h2>
		<p>
			<a href="https://gitee.com/MUCEO/readpress/">
			详细了解 最新 版本。			</a>
		</p>
	</div>
		<div class="welcome-panel-column-container" style="z-index: 8999;">
			<div class="welcome-panel-column">
				<h4><?php _e( '快捷设置' ); ?></h4>
				<ul>
					<?php if ( 'page' == get_option( 'show_on_front' ) && ! get_option( 'page_for_posts' ) ) : ?>
						<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
						<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
					<?php elseif ( 'page' == get_option( 'show_on_front' ) ) : ?>
						<li><?php printf( '<a href="%s" class="welcome-icon welcome-edit-page">' . __( 'Edit your front page' ) . '</a>', get_edit_post_link( get_option( 'page_on_front' ) ) ); ?></li>
						<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( 'Add additional pages' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
						<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( 'Add a blog post' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
					<?php else : ?>
						<li><?php printf( '<a href="%s" class="welcome-icon welcome-write-blog">' . __( '新建文章' ) . '</a>', admin_url( 'post-new.php' ) ); ?></li>
						<li><?php printf( '<a href="%s" class="welcome-icon welcome-add-page">' . __( '新建页面' ) . '</a>', admin_url( 'post-new.php?post_type=page' ) ); ?></li>
					<?php endif; ?>
					<li><?php printf( '<a href="%s" class="welcome-icon welcome-view-site">' . __( '首页' ) . '</a>', home_url( '/' ) ); ?></li>
				</ul>
			</div>
			<div class="welcome-panel-column welcome-panel-last">
				<h4><?php _e( '周边' ); ?></h4>
				<ul>
					<li><?php printf( '<div class="welcome-icon welcome-widgets-menus">' . __( ' <a href="https://www.aj0.cn">作者官网</a>' ) . '</div>', admin_url( 'widgets.php' ), admin_url( 'nav-menus.php' ) ); ?></li>
					<li><?php printf( '<a href="%s" class="welcome-icon welcome-comments">' . __( '讨论设置' ) . '</a>', admin_url( 'options-discussion.php' ) ); ?></li>
					<li><?php printf( '<a href="%s" class="welcome-icon welcome-learn-more">' . __( '项目地址' ) . '</a>', __( 'https://gitee.com/MUCEO/readpress/' ) ); ?></li>
				</ul>
			</div>
		</div>

	</div>
	<?php
}
add_action( 'welcome_panel', 'rc_my_welcome_panel' );